<?php
Class C_User{
    public $id;
    public $username;
    public $panoramio_id;
    public $flickr_id;
    public $status;
    public $authenticate_user = false;
    
    public $ADMIN_USER = 0;
    public $NORMAL_USER = 1;
    public $GUEST_USER = 2;
    
    public function __construct()
    {
        $this->Authenticate_User();
    }
    
    public function isAuthenticated()
    {
        return $this->authenticate_user;
    }
    
    public function Authenticate_User(){
        $this->authenticate_user = true;
        if(isset($_SESSION['user_id'])){
            $this->id = $_SESSION['user_id'];
            if(isset($_SESSION['user_username'])) $this->username = $_SESSION['user_username'];
            else $this->authenticate_user = false;
            if(isset($_SESSION['user_status'])) $this->status = $_SESSION['user_status'];
            else $this->authenticate_user = false;
            if(isset($_SESSION['user_panoramio_id'])) $this->panoramio_id = $_SESSION['user_panoramio_id'];
            else $this->authenticate_user = false;
            if(isset($_SESSION['user_flickr_id'])) $this->flickr_id = $_SESSION['user_flickr_id'];
            else $this->authenticate_user = false;
        }
        else $this->authenticate_user = false;
        return $this->authenticate_user;
    }
    
    public function Logout(){
        if(isset($_SESSION['user_id'])) unset($_SESSION['user_id']);
        if(isset($_SESSION['user_username'])) unset($_SESSION['user_username']);
        if(isset($_SESSION['user_status'])) unset($_SESSION['user_status']);
        $this->authenticate_user = false;
    }
}
?>
